// pages/school/detail/detail.js
var schoolservice = require("../../../apiservice/school/schoolservice");
const jsonData = require("../jsondata.js");
var schoolId = '';
Page({

  /**
   * 页面的初始数据
   */
  data: {
      schoolItem:{},
      stageArray: jsonData.stageArray,
    stageIndex: 0,
    levelArray: jsonData.levelArray,
    levelIndex: 0,
    propertyArray: jsonData.propertyArray,
    propertyIndex: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    schoolId=options.schoolId
    schoolservice.getSchoolDetail(schoolId).then(function(success){
      console.log(success);
      that.setData({
        schoolItem:success.data,
      })
      var stageId = parseInt(that.data.schoolItem.new_stage-1);
      var propertyId =  parseInt(that.data.schoolItem.new_property-1)>2?2:parseInt(that.data.schoolItem.new_property-1);
      var levelId = parseInt(that.data.schoolItem.new_level-1);
      //console.log(stageId);
      that.setData({
        stageIndex:stageId,
        levelIndex:levelId,
        propertyIndex:propertyId
      })
      
    }).catch(function(ex){
      console.log(ex);
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})